import styles from './index.css';
import React, {Component} from 'react';
import {Switch, Route, Redirect} from 'react-router-dom';
import {connect} from 'react-redux';
import Cookies from 'js-cookie'  // 可以操作前端cookie的对象 set()/get()/remove()
import {NavBar} from 'antd-mobile';
import {getUser} from '../redux/actions';

class Main extends Component {
	componentDidMount () {
        //登陆过(cookie中有userid), 但没有登陆(redux管理的user中没有_id) 发请求获取对应的user
        const userid = Cookies.get('userid')
        const {_id} = this.props.user;
        if(userid && !_id) {
            // 发送异步请求, 获取user
            // console.log('发送ajax请求获取user')
            this.props.getUser()
        }
    }
    render () {
    	return (
	        <div>8888</div>
	   	)
    }
}
export default connect(
    state => ({user: state.user, unReadCount: state.chat.unReadCount}),
    {getUser}
)(Main)